import { GetRequest, PostRequest, PutRequest } from '@/utils/request'
import type { Response } from '@/utils/request'

type TimeModel = {
  enabled: number
  startTime: string
  endTime: string
}

export type PersonalPreference = {
  valleyTime: TimeModel
  muteNotification: TimeModel
}
/**
 * 谷电设置，消息免打扰
 */
export function getPersonalPreference(): Promise<Response<PersonalPreference>> {
  return GetRequest('/api/user/personalPreference')
}

/**
 * 保存用户谷电设置
 */
export function saveVallertPersonalPreference(
  enableValleyTime: number,
  valleyStartTime: string,
  valleyEndTime: string
): Promise<Response<string>> {
  return PostRequest('/api/user/savePersonalPreference', {
    enableValleyTime: enableValleyTime,
    valleyStartTime: valleyStartTime,
    valleyEndTime: valleyEndTime,
  })
}

/**
 * 保存消息免打扰设置
 */
export function saveMessagePersonalPreference(
  enableMutNotification: number,
  muteNotificationStartTime: string,
  muteNotificationEndTime: string
): Promise<Response<string>> {
  return PostRequest('/api/user/savePersonalPreference', {
    enableMutNotification: enableMutNotification,
    muteNotificationStartTime: muteNotificationStartTime,
    muteNotificationEndTime: muteNotificationEndTime,
  })
}
